//
//  RegisterViewController.m
//  UI_豆瓣更新版
//
//  Created by dllo on 16/1/3.
//  Copyright © 2016年 lanou3g. All rights reserved.
//

#import "RegisterViewController.h"
#import "LoginView.h"
@interface RegisterViewController ()<UITextFieldDelegate>

@end

@implementation RegisterViewController

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
    }
    return self;
}

- (void)dealloc {
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"注册";
    
    LoginView *view = [[LoginView alloc] initWithFrame:CGRectMake(35, 70, 305, 50)];
    view.myLabel.text = @"用户名:";
    view.myTextField.placeholder = @"请输入用户名";
    
    view.myTextField.delegate = self;
    [self.view addSubview:view];
    [view release];
    
    LoginView *view1 = [[LoginView alloc] initWithFrame:CGRectMake(35, 140, 305, 50)];
    view1.myLabel.text = @"密码:";
    view1.myTextField.placeholder = @"请输入密码";
    view1.myTextField.secureTextEntry = YES;
    view1.myTextField.delegate = self;
    [self.view addSubview:view1];
    [view1 release];
    
    LoginView *view2 = [[LoginView alloc] initWithFrame:CGRectMake(35, 210, 305, 50)];
    view2.myLabel.text = @"确认密码:";
    view2.myTextField.placeholder = @"再次输入密码";
    view2.myTextField.secureTextEntry = YES;
    view2.myTextField.delegate = self;
    [self.view addSubview:view2];
    [view2 release];
    
    LoginView *view3 = [[LoginView alloc] initWithFrame:CGRectMake(35, 280, 305, 50)];
    view3.myLabel.text = @"邮箱:";
    view3.myTextField.placeholder = @"请输入邮箱";
    view3.myTextField.delegate = self;
    [self.view addSubview:view3];
    [view3 release];
    
    LoginView *view4 = [[LoginView alloc] initWithFrame:CGRectMake(35, 350, 305, 50)];
    view4.myLabel.text = @"联系方式:";
    view4.myTextField.placeholder = @"请输入联系方式";
    view4.myTextField.delegate = self;
    [self.view addSubview:view4];
    [view4 release];
    
    UIBarButtonItem *item1 = [[UIBarButtonItem alloc] initWithTitle:@"注册" style:UIBarButtonItemStylePlain target:self action:@selector(buttonAction:)];
    self.navigationItem.rightBarButtonItem = item1;
    
    UIBarButtonItem *item2 = [[UIBarButtonItem alloc] initWithTitle:@"用户登录" style:UIBarButtonItemStylePlain target:self action:@selector(itemAction:)];
    self.navigationItem.leftBarButtonItem = item2;
    
}
// 用户登录按钮方法
- (void)itemAction:(UIBarButtonItem *)item {
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}

// 注册按钮方法
- (void)buttonAction:(UIBarButtonItem *)item {
    
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"用户注册成功" preferredStyle:UIAlertControllerStyleAlert];
        
    [self presentViewController:alert animated:YES completion:nil];
    
    [self performSelector:@selector(dismissAlert) withObject:nil afterDelay:1.5];
}

- (void)dismissAlert {
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    [textField resignFirstResponder];
    return YES;
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
